package Day06;

public class Text1 {
    public static void main(String[] args) {
       Cat cat = new Cat("小猫",23);
        fun2(cat);  //调用cat的eat()方法
        Animal animal = fun1();
        System.out.println(animal.name);
    }

    //父类作为方法的返回值,可以接收任意子类
    public static Animal fun1(){
        Dog dog = new Dog("小狗",234);
        return dog;
    }

    //父类作为方法的参数,可以传输任意子类
    public static void fun2(Animal animal){
        animal.eat();
    }
}
